package com.whfc.openapi.api.fse.controller;

import com.whfc.common.third.deye.DeyeConst;
import com.whfc.common.third.deye.DeyeResult;
import com.whfc.openapi.api.fse.service.OpenApiFseDeyeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 德业特种设备接口
 *
 * @author qzexing
 * @version 1.0
 * @date 2022/3/2 16:18
 */
@RestController
@RequestMapping("/zhgd")
public class FseDeyeController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private OpenApiFseDeyeService openApiFseDeyeService;

    @PostMapping("/LoginDataCrane")
    public DeyeResult loginDataCrane(@RequestBody String data) {
        logger.info("上报塔机注册信息, data:{}", data);
        openApiFseDeyeService.loginDataCrane(data);
        return DeyeResult.success(DeyeConst.LOGIN_DATA_CRANE);
    }

    @PostMapping("/BaseDataCrane")
    public DeyeResult baseDataCrane(@RequestBody String data) {
        logger.info("上报塔机基础参数, data:{}", data);
        openApiFseDeyeService.baseDataCrane(data);
        return DeyeResult.success(DeyeConst.BASE_DATA_CRANE);
    }

    @PostMapping("/RealtimeDataCrane")
    public DeyeResult realtimeDataCrane(@RequestBody String data) {
        logger.info("上报塔机实时数据, data:{}", data);
        openApiFseDeyeService.realtimeDataCrane(data);
        return DeyeResult.success(DeyeConst.REALTIME_DATA_CRANE);
    }

    @PostMapping("/WorkDataCrane")
    public DeyeResult workDataCrane(@RequestBody String data) {
        logger.info("上报塔机工作循环数据, data:{}", data);
        openApiFseDeyeService.workDataCrane(data);
        return DeyeResult.success(DeyeConst.WORK_DATA_CRANE);
    }

    @PostMapping("/AlarmDataCrane")
    public DeyeResult alarmDataCrane(@RequestBody String data) {
        logger.info("上报塔机报警数据, data:{}", data);
        openApiFseDeyeService.alarmDataCrane(data);
        return DeyeResult.success(DeyeConst.ALARM_DATA_CRANE);
    }

    @PostMapping("/AlarmChangeDataCrane")
    public DeyeResult alarmChangeDataCrane(@RequestBody String data) {
        logger.info("上报塔机报警状态改变数据, data:{}", data);
        openApiFseDeyeService.alarmChangeDataCrane(data);
        return DeyeResult.success(DeyeConst.ALARM_CHANGE_DATA_CRANE);
    }

    @PostMapping("/CurveDataCrane")
    public DeyeResult curveDataCrane(@RequestBody String data) {
        logger.info("上传力矩曲线表, data:{}", data);
        openApiFseDeyeService.curveDataCrane(data);
        return DeyeResult.success(DeyeConst.CURVE_DATA_CRANE);
    }

    @PostMapping("/LoginDataElevator")
    public DeyeResult loginDataElevator(@RequestBody String data) {
        logger.info("上报升降机注册信息, data:{}", data);
        openApiFseDeyeService.loginDataElevator(data);
        return DeyeResult.success(DeyeConst.LOGIN_DATA_ELEVATOR);
    }

    @PostMapping("/BaseDataElevator")
    public DeyeResult baseDataElevator(@RequestBody String data) {
        logger.info("上报升降机基础参数, data:{}", data);
        openApiFseDeyeService.baseDataElevator(data);
        return DeyeResult.success(DeyeConst.BASE_DATA_ELEVATOR);
    }

    @PostMapping("/RealtimeDataElevator")
    public DeyeResult realtimeDataElevator(@RequestBody String data) {
        logger.info("上报升降机实时数据, data:{}", data);
        openApiFseDeyeService.realtimeDataElevator(data);
        return DeyeResult.success(DeyeConst.REALTIME_DATA_ELEVATOR);
    }

    @PostMapping("/WorkDataElevator")
    public DeyeResult workDataElevator(@RequestBody String data) {
        logger.info("上报升降机工作循环数据, data:{}", data);
        openApiFseDeyeService.workDataElevator(data);
        return DeyeResult.success(DeyeConst.WORK_DATA_ELEVATOR);
    }

    @PostMapping("/AlarmDataElevator")
    public DeyeResult alarmDataElevator(@RequestBody String data) {
        logger.info("上报升降机报警数据, data:{}", data);
        openApiFseDeyeService.alarmDataElevator(data);
        return DeyeResult.success(DeyeConst.ALARM_DATA_ELEVATOR);
    }

    @PostMapping("/UpImage")
    public DeyeResult upImage(@RequestBody String data) {
        logger.info("上报笼内拍照截图, data:{}", data);
        openApiFseDeyeService.upImage(data);
        return DeyeResult.success(DeyeConst.UP_IMAGE);
    }

    @PostMapping("/OperatorRecord")
    public DeyeResult operatorRecord(@RequestBody String data) {
        logger.info("上报司机打卡记录信息, data:{}", data);
        openApiFseDeyeService.operatorRecord(data);
        return DeyeResult.success(DeyeConst.OPERATOR_RECORD);
    }

    @PostMapping("/GpsData")
    public DeyeResult gpsData(@RequestBody String data) {
        logger.info("上报GPS定位数据, data:{}", data);
        openApiFseDeyeService.gpsData(data);
        return DeyeResult.success(DeyeConst.GPS_DATA);
    }


}
